package com.todo.biz.application.frontend.controller;

import com.todo.biz.application.frontend.service.BizAssociateAggService;
import com.todo.biz.iface.frontend.AssociateFrontendIface;
import com.todo.biz.iface.frontend.request.*;
import com.todo.biz.iface.frontend.response.CollectBusinessDataVO;
import com.todo.biz.iface.frontend.response.LikeBusinessDataVO;
import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/5/28 14:35
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/bizBase/associate")
@Tag(name = "业务关联前台接口", description = "业务关联前台接口")
public class AssociateFrontendController implements AssociateFrontendIface {

    @Resource
    private BizAssociateAggService bizAssociateAggService;


    @Override
    @Operation(summary = "点赞")
    @PostMapping("/likeBusinessData")
    public BizResponse<Boolean> likeBusinessData(@RequestBody LikeBusinessDataParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return bizAssociateAggService.likeBusinessData(param);
    }

    @Override
    @Operation(summary = "收藏")
    @PostMapping("/collectBusinessData")
    public BizResponse<Boolean> collectBusinessData(@RequestBody CollectBusinessDataParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return bizAssociateAggService.collectBusinessData(param);
    }

    @Override
    @Operation(summary = "删除点赞信息")
    @PostMapping("/removeLikeData")
    public BizResponse<Boolean> removeLikeData(@RequestBody RemoveLikeDataParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return bizAssociateAggService.removeLikeData(param);
    }

    @Override
    @Operation(summary = "删除收藏信息")
    @PostMapping("/removeCollectData")
    public BizResponse<Boolean> removeCollectData(@RequestBody RemoveCollectDataParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return bizAssociateAggService.removeCollectData(param);
    }

    @Override
    @Operation(summary = "查询用户点赞列表")
    @PostMapping("/queryLikeBusinessData")
    public BizPageResponse<LikeBusinessDataVO> queryLikeBusinessData(@RequestBody QueryLikeBusinessDataParam param) {
        if (param == null) {
            return BizPageResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.success("查询失败，请刷新后重新操作");
        }
        return bizAssociateAggService.queryLikeBusinessData(param);
    }

    @Override
    @Operation(summary = "查询用户收藏列表")
    @PostMapping("/queryCollectBusinessData")
    public BizPageResponse<CollectBusinessDataVO> queryCollectBusinessData(@RequestBody QueryCollectBusinessDataParam param) {
        if (param == null) {
            return BizPageResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.success("查询失败，请刷新后重新操作");
        }
        return bizAssociateAggService.queryCollectBusinessData(param);
    }
}
